package event.messageevent;

import java.io.Serializable;
import java.util.Vector;

class MessageManager implements Serializable{
	
	private static final long serialVersionUID = 2460739776052822913L;
	private Object Source;
	private Vector<MessageListener> Listeners;
	
	protected MessageManager(Object source){
		this.Source=source;
		Listeners=new Vector<MessageListener> (0,1);
	}
	protected boolean addMessageListener(MessageListener ml){
		return Listeners.add(ml);
	}
	protected boolean removeMessageListener(MessageListener ml){
		return Listeners.remove(ml);
	}
	protected void sendMessageEvent(Object info){
		MessageEvent message=new MessageEvent(this.Source,info);
		for (int i=0; i<Listeners.size();i++){
			Listeners.get(i).ReceivedMessage(message);
		}
	}
}
